package com.sskj.b70.p.activity;

import com.lzy.okgo.model.Response;
import com.sskj.b70.m.HttpConfig;
import com.sskj.b70.m.bean.HttpData;
import com.sskj.b70.m.http.JsonCallBack;
import com.sskj.b70.p.base.BasePresenter;
import com.sskj.b70.utils.ToastUtil;
import com.sskj.b70.v.activity.PwdForgetActivity;

/**
 * <pre>
 *     author : wk_math
 *     e-mail : wk_math@163.com
 *     time   : 2018/03/30
 *     desc   :
 *     version: 1.0
 * </pre>
 */

public class PwdForgetPresenter extends BasePresenter<PwdForgetActivity> {

    public void sendSms(String mobile) {
        httpService.sendCode(mobile, "2")
                .execute(new JsonCallBack<HttpData>(this) {
                    @Override
                    public void _onSuccess(Response<HttpData> response) {
                        HttpData httpListData = response.body();
                        if (httpListData.getStatus() == HttpConfig.STATUS_OK) {
                            mView.checkCode(mobile);
                        } else {
                            ToastUtil.showShort(httpListData.getMsg());
                        }
                    }

                    @Override
                    public void onError(Response<HttpData> response) {
                        super.onError(response);
                    }
                });
    }
    /**
     * 获取短信验证码---codeType 1代表注册  2代表重置密码
     */
    public void sendEmailCode(String email) {
        httpService.sendEmailCode(email)
                .execute(new JsonCallBack<HttpData>(this) {
                    @Override
                    protected void _onSuccess(Response<HttpData> response) {
                        HttpData httpListData = response.body();
                        if (httpListData.getStatus() == HttpConfig.STATUS_OK) {
                            mView.checkCode(email);
                        } else {
                            ToastUtil.showShort(httpListData.getMsg());
                        }
                    }
                    @Override
                    public void onError(Response<HttpData> response) {
                        super.onError(response);


                    }
                });

    }
}
